package cn.flyingocean.spider.impl.com.douban.book;

import cn.flyingocean.exception.SpiderException;
import cn.flyingocean.exception.UnsupportedMiddleTypeException;
import org.jsoup.nodes.Document;
import cn.flyingocean.spider.Spider;

public abstract class AbstractSpider implements Spider{
    /**
     * 通用调用方法
     * @param mid
     * @return
     */
    public Object doWork(Object mid) throws SpiderException {
        if (mid instanceof String) return doWork((String) mid);
        if (mid instanceof Document) return doWork((Document) mid);
        throw new UnsupportedMiddleTypeException();
    }

    /**
     * 默认什么都不做
     * @param r
     */
    public void onCompleted(Object r) {
        return;
    }
}
